<html>
<head>
	<title>Sendmail</title>
</head>
<body>
<?php
include 'Mail.php';
include 'Mail/mime.php' ;

$from = "sendmailpetshop@gmail.com"; //Pass là dn9AV8dX3zm2
$to = "contactpetshop@gmail.com"; //Pass là dn9AV8dX3zm2
$subject = 'Email from customer '.$_REQUEST[fullname].'';

$host = "ssl://smtp.gmail.com";
$port = "465";
$username = "sendmailpetshop@gmail.com";  //<> give errors
$password = "dn9AV8dX3zm2";

$headers = array (
	'From' => $from,
	'To' => $to,
	'Subject' => $subject,
	'Content-Type'  => 'text/html; charset=UTF-8'
);

$mime_params = array(
  'text_encoding' => '7bit',
  'text_charset'  => 'UTF-8',
  'html_charset'  => 'UTF-8',
  'head_charset'  => 'UTF-8'
);

$mime = new Mail_mime();

$html = '
<html>
	<body>
		<style type="text/css">
		a{text-decoration: none; color: #523602;}
		</style>
		Subject: '.$_REQUEST[subject].'
		<br />
		Customer Name: '.$_REQUEST[fullname].'
		<br />
		Customer Email: '.$_REQUEST[email].'
		<br />
		<div style="float: left; border: 0px red solid; width: 350px; text-align: justify;">
		<p>
		'.$_REQUEST[content].'
		</p>
		</div>
	</body>
</html>';

$text = ''.$_REQUEST[fullname].$_REQUEST[email].'<br>'.$_REQUEST[content].'';

$mime->setTXTBody($text);
$mime->setHTMLBody($html);
$body = $mime->get($mime_params);
$headers = $mime->headers($headers);

$smtp = Mail::factory('smtp',
  array ('host' => $host,
	'port' => $port,
	'auth' => true,
	'username' => $username,
	'password' => $password));

$mail = $smtp->send($to, $headers, $body);

if (PEAR::isError($mail)) {
  echo("<p>" . $mail->getMessage() . "</p>");
 } else {
  echo("<script>location.href='../sendmailsuccess.php'</script>");
 }

?>
</body>
</html>